package com.xiaoke.java;

import java.io.FileWriter;
import java.io.IOException;

/**
 * 产生10万个长度不超过10的字符串，包含 a-z, A-Z
 * @author yd
 * @version 1.0
 * @date 2022/2/28 20:06
 */
public class GenerateString {


    public static void main(String[] args) throws IOException {
        FileWriter fw = new FileWriter("words.txt");
        for (int i = 0; i < 100000; i++) {
            //1-10
            int length = (int) (Math.random() * (10 -1 + 1) +1);

            fw.write(getString(length) + "\n");
        }
        fw.close();

    }

    public static String getString(int length) {
        String str = "";
        for (int i = 0; i < length; i++) {
            //65 - 90 97-122
            int num = (int)(Math.random() *(90-65+1) + 65) + (int)(Math.random() * 2 ) *32;
            str += (char)num;
        }


        return str;
    }
}
